home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / dsp / a5611.tz / a5611 / torom.c < prev   
C/C++ Source or Header  |  1992-08-11  |  2KB  |  68 lines

  1. /*******************************************************
  2.  *
  3.  *  a56 - a DSP56001 assembler
  4.  *
  5.  *  Written by Quinn C. Jensen
  6.  *  July 1990
  7.  *  jensenq@npd.novell.com (or jensenq@qcj.icon.com)
  8.  *
  9.  *******************************************************\
  10.  
  11. /*
  12.  * Copyright (C) 1990-1992 Quinn C. Jensen
  13.  *
  14.  * Permission to use, copy, modify, distribute, and sell this software
  15.  * and its documentation for any purpose is hereby granted without fee,
  16.  * provided that the above copyright notice appear in all copies and
  17.  * that both that copyright notice and this permission notice appear
  18.  * in supporting documentation.  The author makes no representations
  19.  * about the suitability of this software for any purpose.  It is
  20.  * provided "as is" without express or implied warranty.
  21.  *
  22.  */
  23. static char *Copyright = "Copyright (C) 1990-1992 Quinn C. Jensen";
  24.  
  25. /*
  26.  *  This program converts the a56.out assembler output file into
  27.  *  raw binary, suitable for conversion to S-records for an EPROM burner.
  28.  *
  29.  */
  30.  
  31.  
  32. #define MAX 256
  33.  
  34. main(argc,argv)
  35. int argc;
  36. char *argv[];
  37. {
  38.     char buf[MAX];
  39.     int curaddr = 0;
  40.     int line = 0;
  41.  
  42.     while(gets(buf)) {
  43.     char seg;
  44.     int addr, data;
  45.     line++;
  46.     if(sscanf(buf, "%c%x%x", &seg, &addr, &data) == 3) {
  47.         if(addr < curaddr) {
  48.         fatal("%s: input line %d: can't go back\n", argv[0], line);
  49.         } else if(addr != curaddr) {
  50.         while(curaddr < addr) {
  51.             putword(0);
  52.             curaddr++;
  53.         }
  54.         }
  55.         putword(data);
  56.         curaddr++;
  57.     }
  58.     }
  59. }
  60.  
  61. putword(data)
  62. int data;
  63. {
  64.     putchar(data >>  0 & 0xFF);
  65.     putchar(data >>  8 & 0xFF);
  66.     putchar(data >> 16 & 0xFF);
  67. }
  68.